
#import "SEGAdvertismentModel.h"
#import <objc/runtime.h>

#if __has_include(<Commom/SEGModel.h>)
#import <Commom/SEGModel.h>
#else
#import "SEGModel.h"
#endif

#if __has_include(<SEGPlatform/SEGPlatformManager.h>)
#import <SEGPlatform/SEGPlatformManager.h>
#else
#import "SEGPlatformManager.h"
#endif

#if __has_include(<Commom/SEGLayoutMacro.h>)
#import <Commom/SEGLayoutMacro.h>
#else
#import "SEGLayoutMacro.h"
#endif

@implementation SEGAdvertisementViewModel
-(instancetype)init{
    if (self == [super init]) {
        _widgetWidth = [UIScreen mainScreen].bounds.size.width ;
        _widgetHeight = kAdvertisementViewHeight;
        _widgetWidth = [UIScreen mainScreen].bounds.size.width - 30;
        _widgetHeight = floor(_widgetWidth * 173.0 / 345.0);
        
        _adSource = [[NSArray alloc]init];
//        _communityModel = [[SEGCommunityLocationViewModel alloc]init];
        _communityName = @"";
    }
    return self;
}
@end

@implementation SEGAdvertismentModel
-(instancetype)init
{
    self = [super init];
    if (self) {
        _typeId = @"";
        _position = @"";
        _pic = @"";
        _updateTime = @"";
        _title = @"";
        _href = @"";
        _runingSecond = @"";
        _type = @"";
        _advertisingId = @"";
    }
    return self;
}

- (void)encodeWithCoder:(NSCoder *)encoder
{
    unsigned int count = 0;
    objc_property_t *propertes = class_copyPropertyList([self class], &count);
    for (int i=0; i<count; i++) {
        const char *propertyName = property_getName(propertes[i]);
        NSString *name = [NSString stringWithUTF8String:propertyName];
        id value = [self valueForKey:name];
        [encoder encodeObject:(value)?value:@"" forKey:name];
    }
}

- (id)initWithCoder:(NSCoder *)decoder
{
    if (self = [super init]) {
        unsigned int count =0;
        objc_property_t *propertes = class_copyPropertyList([self class], &count);
        for (int i = 0; i < count; i++) {
            const char *propertyName = property_getName(propertes[i]);
            NSString *name = [NSString stringWithUTF8String:propertyName];
            id value = [decoder decodeObjectForKey:name];
            [self setValue:(value)?value:@"" forKey:name];
        }
    }
    return self;
}

-(NSString *)description{
    return [self yy_modelDescription];
    
}
@end

